<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<title>云盘首页</title>
<jsp:include page="/public/pub.jsp"></jsp:include>
</head>
<body>
	<jsp:include page="/public/top.jsp"></jsp:include>
	<div class="main-container" id="main-container">
		<script language="javascript">
			function deldir() {//取消分享
				var ids = [];
				$("#listdir input[type=checkbox]").each(function() {
					if (this.checked == true) {
						ids.push(this.value);
					}
				});
				if (ids.length > 0) {
					layer.confirm('取消分享', function(index) {
						$.post('${pageContext.request.contextPath}/cloud/deleteshare.do', {
							ids : ids.join(','),
						}, function(j) {
							if (j.success) {
								location.reload();
							} else {
								alert(json.msg);
							}
						}, 'json');
					});
				} else {
					alert("你没有选择");
				}
			}
			function selectBox() {//选择对应的checkbox
				$("#listdir input[type=checkbox]").each(function() {
					if (this.checked == true) {
						this.checked = false;
					} else {
						this.checked = true;
					}
				});
			}
			$(document).ready(function() {
				$('table th input:checkbox').on('click', function() {
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox').each(function() {
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
				});
			});
		</script>
		<script type="text/javascript">
			try {
				ace.settings.check('main-container', 'fixed')//主界面展开显示
			} catch (e) {
			}
		</script>
		<div class="main-container-inner">
			<a class="menu-toggler" id="menu-toggler" href="#"> <span class="menu-text"></span>
			</a>
			<jsp:include page="/public/left.jsp"></jsp:include>
			<div class="main-content">
				<div class="breadcrumbs" id="breadcrumbs">
					<script type="text/javascript">
						try {
							ace.settings.check('breadcrumbs', 'fixed')//展开breadcrumbs
						} catch (e) {
						}
					</script>
					<div>
						<ul class="breadcrumb">
							<li><i class="icon-home home-icon"></i> <a href="#">首页</a></li>
							<li class="active">我的分享</li>
						</ul>
					</div>
					<c:choose>
						<c:when test="${share=='[]'}">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color:red">您还没有分享过文件哦!</span>
						</c:when>
						<c:otherwise>
							<ul class="breadcrumb">
								&nbsp;&nbsp;
								<input type="button" class="button darkblue" value="取消分享" onclick="deldir()" />
							</ul>
						</c:otherwise>
					</c:choose>
					<!-- .breadcrumb -->
				</div>
				<div class="page-content">
					<!-- /.page-header -->
					<div class="row">
						<div class="col-xs-12">
							<div id="dialog-confirm" class="hide">
								<p class="bigger-110 bolder center grey">
									<i class="icon-hand-right blue bigger-120"></i> 你确定要取消分享么？
								</p>
							</div>
							<!-- PAGE CONTENT BEGINS -->
							<table id="sample-table-1" class="table table-striped table-bordered table-hover">
								<thead>
									<tr>
										<th class="center"><label><input type="checkbox" class="ace" autocomplete="off" /> <span class="lbl"></span> </label></th>
										<th class="center">文件名</th>
										<th class="center">提取码</th>
										<th class="center">分享链接</th>
										<th class="center">分享日期</th>
									</tr>
								</thead>
								<tbody id="listdir">
									<c:forEach items="${share}" var="entry">
										<tr class="center">
											<td><label> <input type="checkbox" class="ace" value="${entry.file_name}" id="dir" autocomplete="off" /> <span class="lbl"></span>
											</label></td>
											<td>${entry.file_name}</td>
											<td>${entry.ecode}</td>
											<td><a href="${pageContext.request.contextPath }/public/extract.jsp?id=${entry.id}&&name=${entry.user_name}">查看分享链接</a></td>
											<td>${entry.time}</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
							<!-- PAGE CONTENT ENDS -->
						</div>
						<!-- /.col -->
					</div>
					<!-- /.row -->
				</div>
				<!-- /.page-content -->
			</div>
			<!-- /.main-content -->
			<jsp:include page="/public/container.jsp"></jsp:include>
		</div>
	</div>
</body>
</html>
